import React from 'react';
import { useDevice } from '@/hooks/useDevice';
import { DeviceAdapterProps } from './index.d';

export const DeviceAdapter: React.FC<DeviceAdapterProps> = ({
  pcComponent: PcComponent,
  mobileComponent: MobileComponent,
}) => {
  const { device } = useDevice();

  // 根据设备类型渲染对应组件
  if (device === 'mobile') {
    return <MobileComponent />;
  }

  if (device === 'pc' && PcComponent) {
    return <PcComponent />;
  }

  // 默认显示mobile版本
  return <MobileComponent />;
};
